package com.feib.soeasy.model;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @title (#)CommissionCodeTable.java<br>
 * @description <br>
 * @author Jimmy Liu<br>
 * @version 1.0.0 2010/11/25
 * @copyright Far Eastern International Bank Copyright (c) 2010<br>
 * @2010/11/24 create by Jimmy Liu<br>
 */
@Entity
@Table(name = "COMMISSION_CODE_TABLE")
public class CommissionCodeTable extends AuditEntity {

    private static final long serialVersionUID = -6552197390627348814L;

    /**
     * PK 值
     */
    private Long commissionCodePk;
    /**
     * 代收交易代碼
     */
    private String commissionCode;

    /**
     * 代收交易代碼名稱
     */
    private String commissionCodeName;
    /**
     * 金額區間起
     */
    private Long amountScopeS;
    /**
     * 金額區間迄
     */
    private Long amountScopeE;
    /**
     * 手續費類別 I:內含 , O:外加
     */
    private String commissionType;
    /**
     * 手續費用
     */
    private Long commissionAmount;
    /**
     * 銀行費用
     */
    private Long bankAmount;

    /**
     * 繳款者費用
     */
    private Long payerAmount;
    
    
    /*
     * 帳單業者負擔
     */
    private Long  groupAmount ;

    /**
     * 適用於哪一個檔案格式
     */
    private List<FormatDefinition> formatDefinitions;

    /**
     * 是否被選取
     */
    private Boolean checked;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="COMMISSION_CODE_PK", nullable=false)
    public Long getCommissionCodePk() {
        return commissionCodePk;
    }

    public void setCommissionCodePk(Long commissionCodePk) {
        this.commissionCodePk = commissionCodePk;
    }

    @Column(name="COMMISSION_CODE", length=5)
    public String getCommissionCode() {
        return commissionCode;
    }

    public void setCommissionCode(String commissionCode) {
        this.commissionCode = commissionCode;
    }

    @Column(name="COMMISSION_CODE_NAME", length=20)
    public String getCommissionCodeName() {
        return commissionCodeName;
    }

    public void setCommissionCodeName(String commissionCodeName) {
        this.commissionCodeName = commissionCodeName;
    }

    @Column(name="AMOUNT_SCOPE_S")
    public Long getAmountScopeS() {
        return amountScopeS;
    }

    public void setAmountScopeS(Long amountScopeS) {
        this.amountScopeS = amountScopeS;
    }
    @Column(name="AMOUNT_SCOPE_E")
    public Long getAmountScopeE() {
        return amountScopeE;
    }

    public void setAmountScopeE(Long amountScopeE) {
        this.amountScopeE = amountScopeE;
    }

    @Column(name="COMMISSION_TYPE", length=1)
    public String getCommissionType() {
        return commissionType;
    }

    public void setCommissionType(String commissionType) {
        this.commissionType = commissionType;
    }

    @Column(name="COMMISSION_AMOUNT")
    public Long getCommissionAmount() {
        return commissionAmount;
    }

    public void setCommissionAmount(Long commissionAmount) {
        this.commissionAmount = commissionAmount;
    }

    @Column(name="BANK_AMOUNT")
    public Long getBankAmount() {
        return bankAmount;
    }

    public void setBankAmount(Long bankAmount) {
        this.bankAmount = bankAmount;
    }

    /**
     * @return the formatDefinitions
     */
    @ManyToMany(mappedBy = "commissionCodeTables")
    public List<FormatDefinition> getFormatDefinitions() {
        return formatDefinitions;
    }


    /**
     * @param formatDefinitions the formatDefinitions to set
     */
    public void setFormatDefinitions(List<FormatDefinition> formatDefinitions) {
        this.formatDefinitions = formatDefinitions;
    }

    /**
     * @return 傳回 checked。
     */
    @Transient
    public Boolean getChecked() {
        return checked;
    }

    /**
     * @param checked 要設定的 checked。
     */
    public void setChecked(Boolean checked) {
        this.checked = checked;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((commissionCodePk == null) ? 0 : commissionCodePk.hashCode());
        return result;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        CommissionCodeTable other = (CommissionCodeTable) obj;
        if (commissionCodePk == null) {
            if (other.commissionCodePk != null)
                return false;
        }
        else if (!commissionCodePk.equals(other.commissionCodePk))
            return false;
        return true;
    }


    /**
     * @return the payerAmount
     */
    @Column(name="PAYER_AMOUNT")
    public Long getPayerAmount() {
        return payerAmount;
    }


    /**
     * @param payerAmount the payerAmount to set
     */
    public void setPayerAmount(Long payerAmount) {
        this.payerAmount = payerAmount;
    }
    
    /**
     * @return the groupAmount
     */
    @Column(name="GROUP_AMOUNT")
    public Long getGroupAmount() {
        return groupAmount;
    }


    /**
     * @param groupAmount the groupAmount to set
     */
    public void setGroupAmount(Long groupAmount) {
        this.groupAmount = groupAmount;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return String.format("CommissionCodeTable [commissionCodePk=%s, commissionCode=%s, commissionCodeName=%s, amountScopeS=%s, amountScopeE=%s, commissionType=%s, commissionAmount=%s, bankAmount=%s,payerAmount=%s,groupAmount=%s , formatDefinitions=%s, checked=%s]", commissionCodePk, commissionCode, commissionCodeName, amountScopeS, amountScopeE, commissionType, commissionAmount, bankAmount,payerAmount,groupAmount, formatDefinitions, checked);
    }

}
